﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;



namespace Fast.Framework.Interfaces
{

    /// <summary>
    /// 更新接口类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IUpdate<T>
    {
        /// <summary>
        /// 作为
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <returns></returns>
        IUpdate<T> As(string tableName);

        /// <summary>
        /// 来自
        /// </summary>
        /// <returns></returns>
        IUpdate<T, T2> From<T2>();

        /// <summary>
        /// 条件
        /// </summary>
        /// <param name="expression">表达式</param>
        /// <returns></returns>
        IUpdate<T> Where(Expression<Func<T, bool>> expression);

        /// <summary>
        /// 条件
        /// </summary>
        /// <param name="whereColumns">条件列</param>
        /// <returns></returns>
        IUpdate<T> Where(params string[] whereColumns);

        /// <summary>
        /// In条件
        /// </summary>
        /// <typeparam name="FieldsType">字段类型</typeparam>
        /// <param name="inFieldsName">In字段名称</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        IUpdate<T> In<FieldsType>(string inFieldsName, params FieldsType[] values);

        /// <summary>
        /// In条件
        /// </summary>
        /// <typeparam name="FieldsType">字段类型</typeparam>
        /// <param name="inFieldsName">In字段名称</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        IUpdate<T> In<FieldsType>(string inFieldsName, List<FieldsType> values);

        /// <summary>
        /// In条件
        /// </summary>
        /// <typeparam name="FieldsType">字段类型</typeparam>
        /// <param name="expression">表达式</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        IUpdate<T> In<FieldsType>(Expression<Func<T, object>> expression, List<FieldsType> values);

        /// <summary>
        /// NotIn条件
        /// </summary>
        /// <typeparam name="FieldsType">字段类型</typeparam>
        /// <param name="notInFieldsName">Not In字段名称</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        IUpdate<T> NotIn<FieldsType>(string notInFieldsName, params FieldsType[] values);

        /// <summary>
        /// NotIn条件
        /// </summary>
        /// <typeparam name="FieldsType">字段类型</typeparam>
        /// <param name="notInFieldsName">Not In字段名称</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        IUpdate<T> NotIn<FieldsType>(string notInFieldsName, List<FieldsType> values);

        /// <summary>
        /// NotIn条件
        /// </summary>
        /// <typeparam name="FieldsType">字段类型</typeparam>
        /// <param name="expression">表达式</param>
        /// <param name="values">值</param>
        /// <returns></returns>
        IUpdate<T> NotIn<FieldsType>(Expression<Func<T, object>> expression, List<FieldsType> values);

        /// <summary>
        /// 执行异步
        /// </summary>
        /// <returns></returns>
        Task<int> ExecuteAsync();
    }

    /// <summary>
    /// 更新接口类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="T2"></typeparam>
    public interface IUpdate<T, T2> : IUpdate<T>
    {
        new
        /// <summary>
        /// 来自
        /// </summary>
        /// <returns></returns>
        IUpdate<T, T2, T3> From<T3>();

        /// <summary>
        /// 条件
        /// </summary>
        /// <param name="expression">表达式</param>
        /// <returns></returns>
        IUpdate<T, T2> Where(Expression<Func<T, T2, bool>> expression);

        /// <summary>
        /// 更新
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <param name="expression">表达式</param>
        /// <returns></returns>
        IUpdate<T, T2> Update(Expression<Func<T, T2, T>> expression);
    }

    /// <summary>
    /// 更新接口类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="T2"></typeparam>
    public interface IUpdate<T, T2, T3> : IUpdate<T, T2>
    {
        /// <summary>
        /// 条件
        /// </summary>
        /// <param name="expression">表达式</param>
        /// <returns></returns>
        IUpdate<T, T2, T3> Where(Expression<Func<T, T2, T3, bool>> expression);

        /// <summary>
        /// 更新
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="T2"></typeparam>
        /// <typeparam name="T3"></typeparam>
        /// <param name="expression">表达式</param>
        /// <returns></returns>
        IUpdate<T, T2, T3> Update(Expression<Func<T, T2, T3, T>> expression);
    }
}
